<?php
/**
 * Created by PhpStorm.
 * User: 陈艺赫
 * Date: 2018/5/3
 * Time: 23:36
 */

namespace app\admin\controller;

use think\Controller;
//use think\Session;
use app\user\model\User;

class Base extends Controller
{
    public function _initialize()
    {
        $isLogin = User::isLogin();
        if (!$isLogin) {
            $this->redirect('Login/index');
        }


        $module = $this->request->module();
        $controller = $this->request->controller();
        $action = $this->request->action();

        $mca = strtolower(sprintf('%s/%s/%s', $module, $controller, $action));
        if (!User::hasPowerFunc($mca) && config('district') == 'T') {
            if ($this->request->isAjax()) {
                $this->error('抱歉!您没有此权限');
            } else {
                return view('public/404');
            }
            exit;
        }
        if (empty(session('last_login_time'))) {
            $this->redirect('Login/showFirstChangePwd');
        }
    }
}
